package hot100.logos61To70;

/**
 * @author logos
 * date 2025/7/16 18:32
 * @version v1.0
 * @Package hot100.logos61To70
 */
public class logos67 {

    /**
     * 67. 寻找旋转排序数组的最小值
     * https://leetcode.cn/problems/find-minimum-in-rotated-sorted-array/?envType=study-plan-v2&envId=top-100-liked
     */
    class Solution {
        public int findMin(int[] nums) {
            int n = nums.length;
            int left = 0;
            int right = n - 2;
            while (left <= right) {
                int mid = left + (right - left) / 2;
                if (nums[mid] >= nums[n - 1]) {
                    left = mid + 1;
                } else {
                    right = mid - 1;
                }
            }
            return nums[left];
        }
    }
}
